﻿using System;
using System.Windows.Forms;

//自定义命名空间
using DreamCube.Foundation.Basic.Utility;

namespace AutoCompile.UI
{
    public partial class AddConfig : Form
    {
        #region "字段"

        private String existItems = String.Empty;

        #endregion

        #region "属性"

        public String ConfigName 
        {
            get { return textBox1.Text; }
        }

        #endregion

        public AddConfig(String existItems)
        {
            this.existItems = existItems;
            InitializeComponent();
        }

        /// <summary>
        /// 判断是否存在同名的配置
        /// </summary>
        /// <returns></returns>
        private Boolean CheckExist()
        {
            if (this.existItems.ContainsEx(textBox1.Text, ";", StringComparison.CurrentCultureIgnoreCase))
            {
                MessageBox.Show("已经存在相同名称的配置!", "重名提醒");
                return false;
            }
            return true;
        }

        /// <summary>
        /// 确定按钮单击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            if (CheckExist())
            {
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
        }

        /// <summary>
        /// 取消按钮单击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.Close();
        }
    }
}
